﻿function getElementsByClass(searchclass, tag) {
    var elems, l, fi, fj;
    var out = new Array();
    var re = new RegExp("(^|\\s)" + searchclass + "(\\s|$)");
    if (tag === null) tag = '*';
    elems = document.getElementsByTagName(tag); l = elems.length;
    fj = 0;
    for (fi = 0; fi < l; fi++) {
        if (re.test(elems[fi].className)) {
            out[fj] = elems[fi];
            fj++;
        }
    }
    return out;
}